package org.lifei.auth.controller;

import org.lifei.auth.dto.LoginDTO;
import org.lifei.auth.service.ILoginService;
import org.lifei.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/login")
@RestController
public class LoginController {
    @Autowired
    private ILoginService loginService;
    @PostMapping
    public AjaxResult login(@RequestBody LoginDTO loginDTO)
    {
        try {
            Map<String,Object> employee = loginService.login(loginDTO);
            return AjaxResult.success(employee);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("登录失败！"+e.getMessage());
        }
    }
}
